/*
 * @Description: 单个数组打印杨辉三角
 * @Author: rendc
 * @Date: 2025-07-25 15:06:41
 * @LastEditors: rendc
 * @LastEditTime: 2025-07-25 15:13:35
 */

import java.util.Arrays;

public class Test04 {

  public static void main(String[] args) {
    int rows = 5;
    int[] row = new int[rows];
    for (int i = 0; i < rows; i++) {
      for (int j = i; j > 0; j--) {
        row[j] += row[j - 1];
      }
      row[i] = 1; // 每行最后一位
      for (int k = 0; k < rows - i - 1; k++) {
        System.out.print(" ");
      }
      for (int n = 0; n <= i; n++) {
        System.out.print(row[n] + " ");
      }
      System.out.println("");
    }
    System.out.println("row:" + Arrays.toString(row));
  }
}